/*
 * parse_ascii.c
 *
 *  Created on: Jan 19, 2014
 *      Author: Raviraj
 */

#include "includes.h"

void parse_ascii(char filename[80])
{
	FILE *IN_FILE;
	char ch;
	unsigned short code = 0;
	unsigned short address = 0;
	int ret;
	IN_FILE = fopen(filename, "r");

	while(!feof(IN_FILE))
	{
		ch = fgetc(IN_FILE);
		if (ch == '@')
		{
			ret = fscanf(IN_FILE, "%o", (int *)&address);
		}
		else if (ch == '-')
		{
			ret = fscanf(IN_FILE,"%o", (int *)&code);
			write_in_memory(address,code,INSTRUCTION);
			address = address + 2;
		}
	}
	ret += 1;
	fclose(IN_FILE);
}
